package cn.iocoder.yudao.module.member.controller.app.technician;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.app.project.vo.AppProjectRespVO;
import cn.iocoder.yudao.module.member.controller.app.technician.vo.AppHealthyRespVO;
import cn.iocoder.yudao.module.member.controller.app.technician.vo.AppTechnicianPageReqVO;
import cn.iocoder.yudao.module.member.controller.app.technician.vo.AppTechnicianRespVO;
import cn.iocoder.yudao.module.member.convert.healthy.AppHealthyConvert;
import cn.iocoder.yudao.module.member.convert.project.AppProjectConvert;
import cn.iocoder.yudao.module.member.convert.technician.AppTechnicianConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.healthy.AppHealthyDO;
import cn.iocoder.yudao.module.member.dal.dataobject.project.AppProjectDO;
import cn.iocoder.yudao.module.member.dal.dataobject.technician.AppTechnicianDO;
import cn.iocoder.yudao.module.member.service.project.AppProjectService;
import cn.iocoder.yudao.module.member.service.technician.AppTechnicianService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@Tag(name = "用户 App - 技师")
@RestController
@RequestMapping("/technician")
@Validated
public class AppTechnicianController {

    @Resource
    private AppTechnicianService appTechnicianService;

    @GetMapping("/page")
    @Operation(summary = "分页获得技师列表")
    public CommonResult<PageResult<AppTechnicianRespVO>> page(@Valid AppTechnicianPageReqVO pageReqVO) {
        PageResult<AppTechnicianDO> technicianPage = appTechnicianService.getTechnicianPage(pageReqVO);
        return CommonResult.success(AppTechnicianConvert.INSTANCE.convertPage(technicianPage));
    }

    @GetMapping("/healthy")
    @Operation(summary = "获得技师健康档案")
    public CommonResult<AppHealthyRespVO> healthy(@RequestParam("id") Long id) {
        AppHealthyDO healthy = appTechnicianService.getHealthyById(id);
        return CommonResult.success(AppHealthyConvert.INSTANCE.convert(healthy));
    }

    @GetMapping
    @Operation(summary = "获得技师详情")
    public CommonResult<AppTechnicianRespVO> info(@RequestParam("id") Long id) {
        AppTechnicianDO technician = appTechnicianService.getTechnicianById(id);
        return CommonResult.success(AppTechnicianConvert.INSTANCE.convert(technician));
    }

}
